home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / vc153.zip / VCS.KEX < prev   
Text File  |  1992-12-20  |  7KB  |  218 lines

  1. * Function:  Display fileone and filetwo in separate windows and locate the
  2. *            next and previous deletion or insertion.
  3. * To run:    While editing the second of two files you wish to compare
  4. *            (filetwo), execute the macro VCS with a fileone parameter (where
  5. *            fileone is the first of two files you wish to compare).  VCS will
  6. *            save fileone and filetwo if necessary, run Visual Compare (using
  7. *            the /D command line option and with the difference file redirected
  8. *            to the file VCS.TMP), load VCS.TMP, and locate the first deletion
  9. *            or insertion.  To locate the next deletion or insertion, press the
  10. *            Alt-N key or the key defined by the EDITV variable "vc_next_key."
  11. *            To locate the previous deletion or insertion, press the ALT-P key
  12. *            or the key defined by the EDITV variable "vc_prev_key."  To toggle
  13. *            between vertical and horizontal windows, press the F9 key or the
  14. *            key defined by the EDITV variable "vc_split_key."  You can also
  15. *            execute the macro VCS with both fileone and filetwo parameters.
  16. *            To execute the macro VCS from the DOS command line, see VCS.BAT.
  17. * Requires:  KEDIT 4.0
  18. * User set EDITV variables:
  19. *   vcs_next_key   default:  "Alt-N"  locate next deletion or insertion
  20. *   vcs_prev_key   default:  "Alt-P"  locate previous deletion or insertion
  21. *   vcs_split_key  default:  "F9"     toggle between vertical and horizontal
  22. *                                     windows
  23. * Internal EDITV variables:
  24. *   vcs_fileone
  25. *   vcs_filetwo
  26. *   vcs.0          number of differences
  27. *   vcs.1...vcs.n  whether each difference is deletion or insertion
  28. *   vcs_current    current difference
  29.  
  30. arg = arg(1)
  31. IF arg = '!split' THEN
  32.     DO
  33.     'extract /screen'
  34.     IF word(screen.1, 1) = 'SIZE' & word(screen.1, 3) = 'SPLIT' THEN
  35.         'set screen 2'
  36.     ELSE
  37.         'set screen 2 v'
  38.     'sos current firstcol'
  39.     exit
  40.     END
  41. 'editv get vcs.0'
  42. IF arg <> '!next' & arg <> '!prev' THEN
  43.     DO
  44.     IF word(arg, 3) = '!cline' THEN
  45.         'macro' defprofile.1()
  46.     vcs_fileone = word(arg, 1)
  47.     vcs_filetwo = word(arg, 2)
  48.     IF vcs_filetwo = '' THEN
  49.         vcs_filetwo = fileid.1()
  50.     'kedit' vcs_fileone '(nodefext'
  51.     IF rc <> 0 THEN
  52.         exit
  53.     vcs_fileone = fileid.1()
  54.     IF alt() THEN
  55.         DO
  56.         'save'
  57.         IF rc <> 0 THEN
  58.             exit
  59.         END
  60.     'kedit' vcs_filetwo '(nodefext'
  61.     IF rc <> 0 THEN
  62.         exit
  63.     vcs_filetwo = fileid.1()
  64.     IF alt() THEN
  65.         DO
  66.         'save'
  67.         IF rc <> 0 THEN
  68.             exit
  69.         END
  70.     'editv put vcs_fileone vcs_filetwo'
  71.     IF word(arg, 3) <> '!cline' THEN
  72.         * Write the difference file to VCS.TMP.
  73.         'dos vcomp' vcs_fileone vcs_filetwo '/D > VCS.TMP'
  74.     'kedit .:.\VCS.TMP (noprof'
  75.     IF rc <> 0 THEN
  76.         exit
  77.     IF size.1() = 0 THEN
  78.         DO
  79.         'quit'
  80.         'erase .:.\VCS.TMP'
  81.         exit
  82.         END
  83.     filetmp = fileid.1()
  84.     * Process VCS.TMP.
  85.     vcs_current = 0
  86.         DO FOREVER
  87.             'kedit' filetmp '(noprof'
  88.             'next'
  89.             IF rc <> 0 THEN
  90.                 DO
  91.                 'quit'
  92.                 'erase .:.\VCS.TMP'
  93.                 leave
  94.                 END
  95.             vcs_current = vcs_current + 1
  96.             'extract /curline'
  97.             * Save whether this difference is a deletion or an insertion.
  98.             vcs.vcs_current = word(curline.3, 3)
  99.             'editv put vcs.'vcs_current
  100.             * Save the corresponding file positions and the end of the deletion
  101.             * or insertion block by naming them.
  102.             'kedit' vcs_fileone '(nodefext'
  103.             'locate :'word(curline.3, 1)
  104.             'set point .vcs1.'vcs_current
  105.             IF vcs.vcs_current = '1' THEN
  106.                 DO
  107.                 * Save end of deletion block.
  108.                 'locate' word(curline.3, 4) + 1
  109.                 'set point .vcs2.'vcs_current
  110.                 END
  111.             'kedit' vcs_filetwo '(nodefext'
  112.             'locate :'word(curline.3, 2)
  113.             'set point .vcs1.'vcs_current
  114.             IF vcs.vcs_current = '2' THEN
  115.                 DO
  116.                 * Save end of insertion block.
  117.                 'locate' word(curline.3, 4) + 1
  118.                 'set point .vcs2.'vcs_current
  119.                 END
  120.         END
  121.     * Clear extra EDITV variables from last run.
  122.     IF datatype(vcs.0, 'n') THEN
  123.         DO i = vcs_current + 1 to vcs.0
  124.         'editv set vcs'.i
  125.         END
  126.     vcs.0 = vcs_current
  127.     'editv put vcs.0'
  128.     'editv get vcs_next_key vcs_prev_key vcs_split_key'
  129.     IF vcs_next_key = '' THEN
  130.         vcs_next_key = 'Alt-N'
  131.     IF vcs_prev_key = '' THEN
  132.         vcs_prev_key = 'Alt-P'
  133.     IF vcs_split_key = '' THEN
  134.         vcs_split_key = 'F9'
  135.     * Define key to find the next deletion or insertion.
  136.     'define' vcs_next_key '"macro vcs !next"'
  137.     * Define key to find the previous deletion or insertion.
  138.     'define' vcs_prev_key '"macro vcs !prev"'
  139.     * Define key to toggle between vertical and horizontal windows.
  140.     'define' vcs_split_key '"macro vcs !split"'
  141.     vcs_current = 0
  142.     'editv put vcs_current'
  143.     arg = '!next'
  144.     END
  145. 'editv get vcs_current'
  146. IF arg = '!next' THEN
  147.     vcs_current = min(vcs_current + 1, vcs.0 + 1)
  148. ELSE
  149.     vcs_current = max(vcs_current - 1, 0)
  150. IF vcs_current < 1 | vcs_current > vcs.0 THEN
  151.     DO
  152.     'emsg No more deletions or insertions'
  153.     exit
  154.     END
  155. 'editv put vcs_current'
  156. * Make sure two windows.
  157. 'extract /screen'
  158. DO i = 1
  159.     IF word(screen.1, i) = '' THEN
  160.         leave
  161. END
  162. IF i <> 4 | word(screen.1, 1) <> 'SIZE' THEN
  163.     'screen 2 v'
  164. * Locate the corresponding file positions in both files and mark the deletion
  165. * or insertion block.  Start with left or top window.
  166. IF lscreen.3() <> 1 | lscreen.4() <> 1 THEN
  167.     'sos tabcmdf'
  168. 'editv get vcs_fileone vcs_filetwo vcs.'vcs_current
  169. * Locate the fileone position.
  170. 'kedit' vcs_fileone '(nodefext'
  171. IF rc <> 0 THEN
  172.     exit
  173. 'locate .vcs1.'vcs_current
  174. IF rc > 1 THEN
  175.     exit
  176. IF vcs.vcs_current = '1' THEN
  177.     DO
  178.     * Mark the deletion block.
  179.     'reset block'
  180.     i = line.1()
  181.     'locate 1'
  182.     'mark line'
  183.     'locate .vcs2.'vcs_current
  184.     IF rc > 1 THEN
  185.         exit
  186.     'locate -1'
  187.     'mark line'
  188.     IF line.1() = i THEN
  189.         'reset block'
  190.     'locate :'i
  191.     END
  192. * Move to right or bottom window.
  193. 'sos tabcmdf'
  194. * Locate the filetwo position.
  195. 'kedit' vcs_filetwo '(nodefext'
  196. IF rc <> 0 THEN
  197.     exit
  198. 'locate .vcs1.'vcs_current
  199. IF rc > 1 THEN
  200.     exit
  201. IF vcs.vcs_current = '2' THEN
  202.     DO
  203.     * Mark the insertion block.
  204.     'reset block'
  205.     i = line.1()
  206.     'locate 1'
  207.     'mark line'
  208.     'locate .vcs2.'vcs_current
  209.     IF rc > 1 THEN
  210.         exit
  211.     'locate -1'
  212.     'mark line'
  213.     IF line.1() = i THEN
  214.         'reset block'
  215.     'locate :'i
  216.     END
  217. 'sos current firstcol'
  218.